home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_02 / private / _cattr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-17  |  2.5 KB  |  102 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3.  
  4. #ifdef PDCDEBUG
  5. char *rcsid__cattr = "$Header: C:\CURSES\private\RCS\_cattr.c 2.1 1993/06/18 20:23:10 MH Rel MH $";
  6. #endif
  7.  
  8.  
  9.  
  10.  
  11. /*man-start*********************************************************************
  12.  
  13.   PDC_chg_attr_pair()    - Writes character and attribute to physical screen
  14.  
  15.   PDCurses Description:
  16.      This is a private PDCurses function.
  17.  
  18.      Writes a single character 'chr' with attribute 'attr' to the
  19.      current cursor location.
  20.  
  21.      NOTE:    Though passed as 16 bit quantities, only the lower 8 bits
  22.          will be used to create a character/attribute pair.
  23.  
  24.   PDCurses Return Value:
  25.      This function returns OK on success and ERR on error.
  26.  
  27.   PDCurses Errors:
  28.      No errors are defined for this function under DOS.
  29.  
  30.      An ERR may be returned under FLEXOS if s_copy() fails.  See the
  31.      Flexos Programmer's Reference Manual for details on the error.
  32.  
  33.   Portability:
  34.      PDCurses    int PDC_chg_attr_pair( chtype chr, chtype attr );
  35.  
  36. **man-end**********************************************************************/
  37.  
  38. int    PDC_chg_attr_pair(chtype chr, chtype attr)
  39. {
  40.     extern unsigned    char atrtab[MAX_ATRTAB];
  41.     chtype    phys_attr=chtype_attr(attr);
  42.  
  43. #ifdef    OS2
  44.     USHORT curCol, curRow, cell;
  45. #endif
  46.  
  47. #ifdef    FLEXOS
  48.     UBYTE    c = (UBYTE) chr;
  49.     UBYTE    a = (UBYTE) phys_attr;
  50. #endif
  51.  
  52. #ifdef PDCDEBUG
  53.     if (trace_on) PDC_debug("PDC_chg_attr_pair() - called\n");
  54. #endif
  55.  
  56. #ifdef    FLEXOS
  57.     drect.r_row = PDC_get_cur_row();
  58.     drect.r_col = PDC_get_cur_col();
  59.     drect.r_nrow = 1;
  60.     drect.r_ncol = 1;
  61.  
  62.     sframe.fr_pl[0] = (UBYTE *) & c;
  63.     sframe.fr_pl[1] = (UBYTE *) & a;
  64.     sframe.fr_pl[2] = (UBYTE *) " ";
  65.     sframe.fr_nrow = 1;
  66.     sframe.fr_ncol = 1;
  67.     sframe.fr_use = 0x00;
  68.  
  69.     srect.r_col = 0;
  70.     srect.r_row = 0;
  71.     srect.r_nrow = 1;
  72.     srect.r_ncol = 1;
  73.  
  74.     retcode = s_copy(0x03, 0x01L, 0L, (far unsigned short *) &drect, (far unsigned short *) &sframe, (far unsigned short *) &srect);
  75.     return( (retcode < 0L) ? ERR : OK );
  76. #endif
  77.  
  78. #ifdef    DOS
  79.     regs.h.ah = 0x09;
  80.     regs.h.al = chr & A_CHARTEXT;
  81.     regs.h.bh = _cursvar.video_page;
  82.     regs.h.bl = (phys_attr & A_ATTRIBUTES) >> 8;
  83.     regs.x.cx = 0x01;
  84.     int86(0x10, ®s, ®s);
  85.     return( OK );
  86. #endif
  87.  
  88. #ifdef    OS2
  89.     /* find the current cursor position */
  90.     VioGetCurPos((PUSHORT) &curRow, (PUSHORT) &curCol, 0);
  91.     cell = (chr & A_CHARTEXT) | (phys_attr & A_ATTRIBUTES);
  92.     VioWrtNCell((PBYTE)&cell,1,curRow,curCol,0);
  93.     return( OK );
  94. #endif
  95.  
  96. #ifdef UNIX
  97. /* INCOMPLETE - check attribute and output attr and/or color */
  98.     putchar(chr & A_CHARTEXT);
  99.     return(OK);
  100. #endif
  101. }
  102.